#!/bin/sh

HTTPD_ROOTDIR='/var/www'

FILES=$(ldd /usr/local/bin/python2.4 | grep '/usr/' | awk '{print $NF}' | grep -v ':$')

for i in ${FILES}
do
    DIR_IN_CHROOTED="${HTTPD_ROOTDIR}/$(dirname $i)/"
    #echo ${DIR_IN_CHROOTED}

    echo "Create directory: ${DIR_IN_CHROOTED}."
    mkdir -p ${DIR_IN_CHROOTED} 2>/dev/null

    echo "Copy file: $i -> $DIR_IN_CHROOTED."
    cp -rf $i ${DIR_IN_CHROOTED}

    echo ""
done

echo "Create directories: /usr/local/include/"
mkdir -p ${HTTPD_ROOTDIR}/usr/local/include/ 2>/dev/null

echo "Copy files to ${HTTPD_ROOTDIR}."
cp -f /usr/local/bin/python* ${HTTPD_ROOTDIR}/usr/local/bin/

cp -rf /usr/local/lib/python2.4/ ${HTTPD_ROOTDIR}/usr/local/lib/
cp -rf /usr/local/include/python2.4/ ${HTTPD_ROOTDIR}/usr/local/include/
